import { pageLabel } from '@/services/api/api-datahub-label';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import React, { useRef } from 'react';

interface TableLabelProps {
  onSaveSuccess: () => void;
}
const TableLabel: React.FC<TableLabelProps> = ({ onSaveSuccess }) => {
  const userRef = useRef<ActionType>();

  const nickNames = useRef<Array<{ name: string }>>([]);

  const columns: ProColumns<DatahubLabelData.LabelPage>[] = [
    {
      title: 'ID',
      key: 'id',
      dataIndex: 'id',
    },
    {
      title: '名称',
      key: 'name',
      dataIndex: 'name',
    },
  ];
  /**
   * 请求网络
   * @param value
   */
  const request = async (params = {}) => {
    const response = await pageLabel({
      ...params,
    });

    return Promise.resolve({
      data: response.data.data,
      total: response.data.total,
      success: response.code === 0,
    });
  };

  return (
    <ProTable<DatahubLabelData.LabelPage>
      // ghost
      // search={false}
      columns={columns}
      actionRef={userRef}
      request={request}
      sticky
      rowKey="id"
      tableLayout="fixed"
      dateFormatter="string"
      bordered
      pagination={{
        showQuickJumper: true,
        showSizeChanger: true,
        defaultPageSize: 20,
      }}
    />
  );
};
export default TableLabel;
